package com.company.test16;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * Created by Administrator on 2016.6.11.
 */
public class Test16_03 extends JFrame{
    public Test16_03(){
        JButton jbtNew=new JButton("New");
        JButton jbtOpen=new JButton("Open");
        JButton jbtSave=new JButton("Save");
        JButton jbtPrint=new JButton("Print");

        JPanel panel=new JPanel();
        panel.add(jbtNew);
        panel.add(jbtOpen);
        panel.add(jbtSave);
        panel.add(jbtPrint);

        jbtNew.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("New");
            }
        });

        jbtOpen.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("Open");
            }
        });

        jbtPrint.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("Print");
            }
        });

        jbtSave.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                System.out.println("Save");
            }
        });

        this.add(panel);
    }

    public static void main(){
        Test16_03 frame=new Test16_03();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.setTitle("for the lich king");
        frame.setLocationRelativeTo(null);
        frame.pack();
        frame.setVisible(true);
    }
}
